package hd.cls5;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * @author oldliu
 * @since 1.0
 */
public class CompTest {
    public static void main(String[] args) {
        List<Employee> list = new ArrayList<>();
        list.add(new Employee("张三", 30, "男", "程序员", 10000, 1));
        list.add(new Employee("李四", 25, "女", "设计师", 8000, 2));
        list.add(new Employee("王五", 35, "男", "项目经理", 15000, 3));
        list.add(new Employee("Tangmu", 29, "男", "项目经理", 1000, 3));

        Employee e2 = new Employee("周小武", 35, "男", "项目经理", 15000, 3);
        System.out.println(list.contains(e2));
        Collections.sort(list);//默认是升序
        System.out.println("排序后：");
        for (Employee ee : list) {
            System.out.println(ee);
        }
        System.out.println("按照姓名比较规则");//lambda::
        Collections.sort(list, (o1, o2) -> {
            return o2.getName().compareTo(o1.getName());
        });
//        Collections.sort(list, new Comparator<Employee>() {
//            @Override
//            public int compare(Employee o1, Employee o2) {
//                return o1.getName().compareTo(o2.getName());
//            }
//        });
        System.out.println("姓名排序后：");
        for (Employee ee : list) {
            System.out.println(ee);
        }
    }
}
